package com.yoyo.framework.shiro.session;

import com.yoyo.common.enums.OnlineStatus;
import lombok.Data;
import org.apache.shiro.session.mgt.SimpleSession;

/**
 * @author zyl
 * @Date 2021/7/3 -15:09
 */
@Data
public class OnlineSession extends SimpleSession {
    private static final long serialVersionUID = 1L;
    private Long userId;
    private String loginName;
    private String deptName;
    private String avatar;
    private String host;
    private String browser;
    private String os;
    private OnlineStatus status = OnlineStatus.on_line;
    private transient boolean attributeChanged = false;

    @Override
    public String getHost() {
        return host;
    }

    @Override
    public void setHost(String host) {
        this.host = host;
    }

    public void markAttributeChanged() {
        this.attributeChanged = true;
    }

    public void resetAttributeChanged() {
        this.attributeChanged = false;
    }

    public boolean isAttributeChanged() {
        return attributeChanged;
    }

    @Override
    public void setAttribute(Object key, Object value) {
        super.setAttribute(key, value);
    }

    @Override
    public Object removeAttribute(Object key) {
        return super.removeAttribute(key);
    }
}
